﻿using BZhanHengjicvWPF.Common.Models;
using BZhanHengjicvWPF.Extensions;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BZhanHengjicvWPF.ViewModels
{
    public class SettingsViewModel : BindableBase
    {
        public IRegionManager regionManager;
        public SettingsViewModel(IRegionManager regionManager)
        {
            CreatMenus();
            this.regionManager = regionManager;
        }
        private ObservableCollection<MenuBar> menuBars = new ObservableCollection<MenuBar>();

        public ObservableCollection<MenuBar> MenuBars
        {
            get { return menuBars; }
            set { menuBars = value; RaisePropertyChanged(); }
        }
        public DelegateCommand<MenuBar> NavigateCommand { get { return new DelegateCommand<MenuBar>(Navigate); } }

        private void Navigate(MenuBar obj)
        {
            if (obj.Icon == null || string.IsNullOrWhiteSpace(obj.NameSpace))
                return;
            regionManager.Regions[PrismManager.SettingViewRegionName].RequestNavigate(obj.NameSpace);
        }

        void CreatMenus()
        {
            MenuBars.Add(new MenuBar() { Icon = "Palette", Title = "个性化", NameSpace = "SkinView" });
            MenuBars.Add(new MenuBar() { Icon = "Notebook", Title = "系统设置", NameSpace = "" });
            MenuBars.Add(new MenuBar() { Icon = "NotebookEditOutline", Title = "关于更多", NameSpace = "AboutView" });
            
        }
    }
}
